package top.saodisheng.pojo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Proxy;

import javax.persistence.*;
import java.util.Date;

/**
 * Description:
 *
 * @author 扫地生_saodisheng
 */
@Entity
@Table(name = "order_")     // 表名不能用order，因为它是MySQL的关键字
@JsonIgnoreProperties({"handle", "hibernateLazyInitializer"})
@Proxy(lazy = false)

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Order {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private int id;

    @ManyToOne
    @JoinColumn(name = "cid")
    private User consignee;     // 收货人

    @ManyToOne
    @JoinColumn(name = "sid")
    private User sender;        // 寄件人

    @ManyToOne
    @JoinColumn(name = "vid")
    private Vehicle vehicle;     // 配送方式

    @ManyToOne
    @JoinColumn(name = "staffid")
    private Staff staff;     // 配送人员

    @ManyToOne
    @JoinColumn(name = "pid")
    private Package pg;     // 包裹

    // 中间变量
    @Transient
    private int sid;
    @Transient
    private int cid;
    @Transient
    private int vid;
    @Transient
    private int staid;
    @Transient
    private int pid;


    private Date createDate;
    private Date deliveryDate;
    private float freight;      // 订单费用
}
